<template>
    <div class="goods-box3">
        <div class="search">
            <el-input maxlength="100" clearable style="width:290px;" v-model="pagination.searchValue" />
            <img src="../assets/img/search.png" class="search-icon" @click="searchChange" />
            <i style="color:#696969;font-size:12px;font-style:normal;">热门搜索：
                <a class="tag-item" @click="handleTopicDetail('苹果果树种植方法')">苹果果树种植方法 </a> <a class="tag-item"
                    @click="handleTopicDetail('新疆哈密瓜甜度控制')">新疆哈密瓜甜度控制</a> <a class="tag-item"
                    @click="handleTopicDetail('玉米苗灌溉')">玉米苗灌溉</a>
            </i>
        </div>
        <div class="goods" v-for="item in questions" :key="item.id">
            <div class="info">
                <p class="content">
                    <i class="question-text" style="" v-if="item.status == 0">[问]</i>
                    <i class="question-text" v-else>[答]</i>
                    <span class="question-content">{{ item.question }}</span>
                </p>
                <div class="person-contents">
                    <span>提问者：{{ item.questioner }}</span>&nbsp;&nbsp;&nbsp;
                    <span>专家：{{ item.expertName }}</span>
                </div>
            </div>
        </div>
        <Pagination :pagination="pagination" @currentChange="currentChange"></Pagination>
    </div>
</template>

<script lang="ts" setup>


const { questions,pagination } = defineProps({
    questions: {
        type: Object,
        default: [
            {
                id: '',
                status: 0,
                questioner: '',
                expertName: '',
                question: ''
            }
        ]
    },
    pagination: {
        type: Object,
        default: {
            size: 10,
            total: 0,
            page: 1,
            searchValue: ''
        }
    }
})


const emit = defineEmits(['currentChange', 'searchChange'])

const currentChange = (val: number) => {
    emit('currentChange', val)
}

const searchChange = () => {
    emit('searchChange', pagination.searchValue)
}

function handleTopicDetail(str: string) {
    emit('searchChange', str)
}

</script>

<style lang="less" scoped>
.search {
    width: 730px;
    height: 80px;
    background-color: white;
    padding: 10px 20px;

    .tag-item {
        margin-right: 8px;
        cursor: pointer;
    }

    .search-icon {
        position: relative;
        bottom: -13px;
        left: -2px;
        cursor: pointer;
    }
}

.goods-box3 {
    width: 730px;

    .goods {
        width: 730px;
        min-height: 80px;
        padding: 10px 20px;
        background-color: white;
        border-radius: 0px;
        border-bottom: 1px solid #f2f2f2;

        .info {
            width: 685px;

            .title {
                /*超出的部分隐藏*/
                overflow: hidden;
                /*文字用省略号替代超出的部分*/
                text-overflow: ellipsis;
                /*弹性伸缩盒子模型显示*/
                display: -webkit-box;
                /*限制在一个块元素显示文本的行数*/
                -webkit-line-clamp: 1;
                /*设置或检索伸缩盒对象的子元素排列方式*/
                -webkit-box-orient: vertical;
            }

            .content {
                width: 680px;
                line-height: 20px;
                display: flex;
                flex-direction: row;
                justify-content: flex-start;
                align-items: center;
                /*超出的部分隐藏*/
                overflow: hidden;
                /*文字用省略号替代超出的部分*/
                text-overflow: ellipsis;
                /*弹性伸缩盒子模型显示*/
                display: -webkit-box;
                /*限制在一个块元素显示文本的行数*/
                -webkit-line-clamp: 7;
                /*设置或检索伸缩盒对象的子元素排列方式*/
                -webkit-box-orient: vertical;

                .question-text {
                    color: #666;
                    font-style: normal;
                }
            }

            .person-contents {
                display: flex;
                flex-direction: row;
                justify-content: flex-end;
                font-size: 12px;
                color: #666;
            }

            .price {
                font-size: 15px;
                font-weight: bold;
                display: block;
                color: red;
            }
        }
    }
}

.marginR5 {
    margin-right: 5px;
}

.question-content {
    cursor: pointer;

    &:hover {
        text-decoration: underline;
        color: #035D1C;
    }
}

.search /deep/ .el-input--suffix .el-input__inner {
    height: 35px;
    line-height: 35px;
}
</style>